/*
 *  test_argParsing.cpp
 *
 *  Created by Pete Willemsen on 10/6/09.
 *  Copyright 2009 Department of Computer Science, University of Minnesota-Duluth. All rights reserved.
 *
 * This file is part of the UMD CS5651 Computer Networks library (CS5651).
 *
 * CS5651 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * CS5651 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with CS5651.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <iostream>
#include <cstdlib>
#include "handleArgs.h"
#include "GetAddress.h"
#include "GetHostName.h"

using namespace cs5651;

void printEndian();

int main(int argc, char *argv[])
{
  NetworkArgs args;
  args.process(argc, argv);
  /*

  std::cout << "Processed Network Arguments:" << std::endl;
  std::cout << "\thostname = \"" << args.hostname << "\"" << std::endl;
  std::cout << "\thostip = \"" << args.hostip << "\"" << std::endl;
  std::cout << "\tverbose mode = " << (args.verbose == 0 ? "False" : "True") << std::endl;
  */

  printEndian();

  if(args.hostname != ""){
    std::cout << "The address of " << args.hostname << " is: " << std::endl;
    GetAddress(args.hostname.c_str());
  }
 
  if(args.hostip != ""){\
    std::cout << "The Host name of: " << args.hostip << " is: " << std::endl;
    GetHostName(args.hostip.c_str());
  }

  exit(EXIT_SUCCESS);
}


void printEndian(){
  unsigned int i = 1;
  char* I = (char*)&i;
  if(I[0] == I[1]){
    std::cout << "This is a big endian machine" << std::endl;
  }
  else{
    std::cout<< "This is a little endian machine" << std::endl;
  }
}
